import pygame
from game import Game


class Item:
    def __init__(self, x, y, velocity, direction):
        self.velocity = velocity
        self.image2 = pygame.image.load('img/砖块.png')
        self.image = pygame.transform.scale(self.image2, (50, 50))
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y
        self.direction = direction
        self.speed = 8

    def bullet_display(self):
        self.rect.y += self.velocity[1] - 5
        self.rect.y = self.rect.y
        self.velocity[1] += 0.4  # 模拟重力f
        if self.direction == "left":
            Game.window.blit(self.image, (self.rect.x, self.rect.y))
        elif self.direction == "right":
            Game.window.blit(self.image, (self.rect.x, self.rect.y))

    def bullet_fire(self):
        if self.direction == "left":
            self.rect.x -= self.speed
        elif self.direction == "right":
            self.rect.x += self.speed
